package com.le.tester.niuke;

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.http.HttpRequest;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.util.EntityUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.UUID;

/**
 * createTime：2022/1/20 9:24
 * description：
 */
public class TestDemo {

    static void dianping() {
        System.out.println("dianping");
    }

    public static void main(String[] args) throws IOException {
        Thread thread = new Thread(() -> {
            dianping();
        });
        //.run()可以视为简单的调用了run方法
        //thread.run();
        //.start()线程就有了先后之分，按照现在的代码就有不确定性
        thread.start();
        System.out.println("dazhong");
        System.out.println(UUID.randomUUID().toString().replace("-", "").substring(0, 16));

        CloseableHttpClient httpclient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
        HttpPost httpPost = new HttpPost("https://ibsbjstar.ccb.com.cn/CCBIS/B2CMainPlat_05_EPAY?REMARK1=PC&REMARK2=pcPayDev&BRANCHID=351000000&TXCODE=530550&CCB_IBSVersion=V6&CURCODE=01&MERCHANTID=105000282994539&RETURNTYPE=3&ORDERID=282994539749pc&POSID=042078828&PAYMENT=0.01&MAC=9383162f5430664cf5e51538e55829d2&TIMEOUT=&QRCODE=1&CHANNEL=1");
        CloseableHttpResponse response = httpclient.execute(httpPost);



        String s = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
        JSONObject jsonObject = JSONObject.parseObject(s);
        String qrurl = String.valueOf(jsonObject.get("QRURL"));
        System.out.println("获取到的qrurl:" + qrurl);
        String result = URLDecoder.decode(qrurl, StandardCharsets.UTF_8.toString());
        System.out.println("获取到的转换的url：" + result);
    }
}
